<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>堆栈的练习</title>
    <link rel='stylesheet' href='//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/styles/default.min.css'>
    <script src='//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/highlight.min.js'></script>
</head>
<body>
    <pre>
        <code>
            // let a = 10
        // let person = {
        //     age:a
        // }
        // console.log(person); // person.a = 10
        // let son = person // {age = 10}
        // a = 120
        // console.log(person); // {age:10}
        // console.log(son); // {age:10}



        // demo 
        let n = [10,20] // n [100,20]
        let m = n // m [10,20]
        let x = m // x [10,20]
        m[0] = 100 // m [100,20]
        x = [30,40] // x = [30,40]
        x[0] = 200 // x = [200,40]
        m = x // m [200,40]
        m[1] = 300 // m = [200,300] m和x共用一个地址
        n[2] = 400 // n = [100,20,400]

        console.log(n,m,x); // [100,20,400],[200,300],[200,300]

        // 阿里一道面试题
        let a = {
            n:1
        }
        let b = a
        a.x = a = {
            n:2
        }
        console.log(a.x); // undefined
        console.log(b); // {n:1,x:{n:2}}

        let aa = {nn:1}
        let bb = aa
        aa.xx = bb
        // console.log(
        //     aa
        // );
        </code>
    </pre>
    <img src="image.png" width="100%" alt="" srcset="">
    <img src="./image-2.png"  width="100%" alt="" srcset="">
    <img src="./image-1.png" width="100%"  alt="" srcset="">
    <script>hljs.highlightAll()</script>
    <script>
        // let a = 10
        // let person = {
        //     age:a
        // }
        // console.log(person); // person.a = 10
        // let son = person // {age = 10}
        // a = 120
        // console.log(person); // {age:10}
        // console.log(son); // {age:10}



        // demo 
        let n = [10,20] // n [100,20]
        let m = n // m [10,20]
        let x = m // x [10,20]
        m[0] = 100 // m [100,20]
        x = [30,40] // x = [30,40]
        x[0] = 200 // x = [200,40]
        m = x // m [200,40]
        m[1] = 300 // m = [200,300] m和x共用一个地址
        n[2] = 400 // n = [100,20,400]

        console.log(n,m,x); // [100,20,400],[200,300],[200,300]

        // 阿里一道面试题
        let a = {
            n:1
        }
        let b = a
        a.x = a = {
            n:2
        }
        console.log(a.x); // undefined
        console.log(b); // {n:1,x:{n:2}}

        let aa = {nn:1}
        let bb = aa
        aa.xx = bb
        // console.log(
        //     aa
        // );


    </script>
</body>
</html>